from typing import List


class Solution:
    def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
        map = {}
        stack = []
        for num in nums2:
            while len(stack) and stack[len(stack)-1] < num:
                map[stack.pop()] = num
            stack.append(num)
        
        return [map.get(num, -1) for num in nums1]
          